package com.neusoft.control;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.alibaba.fastjson.JSON;
import com.neusoft.bean.AdminInfoBean;
import com.neusoft.bean.AdminInfoBeanQuery;
import com.neusoft.myutils.MyUtil;
import com.neusoft.service.AdminInfoService;

@WebServlet("/AjaxQueryAdminInfoServlet")
public class AjaxQueryAdminInfoServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		//获取查询表单数据
		AdminInfoBeanQuery adminBQ = MyUtil.convertRequestParameters2Bean(request, AdminInfoBeanQuery.class);
		List<AdminInfoBean> aiblst = MyUtil.getInstance(AdminInfoService.class).getAdminInfo(adminBQ);
		// 将结果集转换为json字符串

				String strJsonListAdmins = JSON.toJSONStringWithDateFormat(aiblst, "yyyy-MM-dd HH:mm:ss");
				System.out.println("Json:"+strJsonListAdmins);
				// 在跳转页面之前，将查询结果使用response的writer对象将影响内容写出到客户端（类似于socket通信时的响应）

				PrintWriter pw = response.getWriter();
				pw.write(strJsonListAdmins);
				// 清空

				pw.flush();
				// 关闭资源

				pw.close();
	}

}
